﻿@page "/_StudentMajor/StudentMajor/Details/{id}"
@using WBBvNext.ViewModel._StudentMajor.StudentMajorVMs;
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" >
    <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.FormRow">

            <Display @bind-Value="@Model.Entity.MajorId" Data="@AllMajors"  ShowLabel="true"/>
            <Display @bind-Value="@Model.Entity.StudentId" Data="@AllStudents"  ShowLabel="true"/>
    </Row>
    <div class="modal-footer table-modal-footer">
        <Button Color="Color.Primary" Icon="fa fa-save" Text="@WtmBlazor.Localizer["Sys.Close"]" OnClick="OnClose" />
    </div>
</ValidateForm>

@code {

    private StudentMajorVM Model = null;
    private ValidateForm vform { get; set; }
    [Parameter]
    public string id { get; set; }

    private List<SelectedItem> AllMajors = new List<SelectedItem>();

    private List<SelectedItem> AllStudents = new List<SelectedItem>();


    protected override async Task OnInitializedAsync()
    {

        AllMajors = await WtmBlazor.Api.CallItemsApi("/api/StudentMajor/GetMajors", placeholder: WtmBlazor.Localizer["Sys.All"]);

        AllStudents = await WtmBlazor.Api.CallItemsApi("/api/StudentMajor/GetStudents", placeholder: WtmBlazor.Localizer["Sys.All"]);

        var rv = await WtmBlazor.Api.CallAPI<StudentMajorVM>($"/api/StudentMajor/{id}");
        Model = rv.Data;
    }

    public void OnClose()
    {
        CloseDialog();
    }

}
